<!--  -->
<template>
  <div class="promocode">
    <div class="navheader borderbox">
      <img src="../assets/img/icon-back.png" class="back" @click="goBack" />
      <div class="title">我的邀请码</div>
    </div>
    <div class="promocode-box borderbox">
      <div class="item-box">
        <div class="item-left">
          <div v-if="!promoCode.code" class="value">暂无</div>
          <div v-else class="value">{{ promoCode.code }}</div>
          <div class="tit">我的邀请码</div>
          <div class="btn-copy">复制</div>
        </div>
        <div class="item-right">
          <div class="value">￥{{ promoCode.per_order_draw }}</div>
          <div class="tit">邀请奖励金</div>
        </div>
      </div>
      <div class="info">
        <p>邀请者分享邀请链接给其他人下单成功后，将的到如下对应金额奖励：</p>
        <p>邀请人奖励：0元</p>
        <p>被邀请人奖励：0元</p>
        <p>订单抽成：0%</p>
      </div>
    </div>
    <div class="type-box borderbox">
      <div
        class="item"
        v-for="(item, index) in list"
        :key="item"
        :class="{ active: current == index }"
        @click="change(index)"
      >
        {{ item }}
        <div class="actline"></div>
      </div>
      <!-- <div class="item">
        资金明细
        <div class="actline"></div>
      </div>
      <div class="item">
        提现明细
        <div class="actline"></div>
      </div> -->
    </div>
    <div class="empty-box">
      <div class="image-empty-item">
        <img src="../assets/img/img-placeholder.png" />
      </div>
    </div>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      promoCode: {},
      current: 0,
      list: ["邀请记录", "资金明细", "提现明细"],
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    goBack() {
      this.$router.go(-1);
    },
    change(index) {
      this.current = index;
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  async created() {
    let inviteUsers = await this.$request.get("api/v2/member/inviteUsers", {
      page: "1",
      size: "10",
      loading: true,
    });
    console.log(inviteUsers);
    let promoCode = await this.$request.get("api/v2/member/promoCode");
    console.log(promoCode);
    this.promoCode = promoCode.data;
  },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang="less" scoped>
.promocode {
  .navheader.borderbox {
    width: 100%;
    height: 50px;
    background-color: #fff;
    z-index: 100;
    padding-left: 15px;
    padding-right: 15px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    border-bottom: 1px solid #f1f2f6;
    align-items: center;
    box-sizing: border-box;
    img.back {
      position: absolute;
      left: 15px;
      width: 19px;
      height: 19px;
    }

    .title {
      width: 72%;
      height: auto;
      font-size: 17px;
      font-weight: 500;
      text-align: center;
      color: #333;
      line-height: 22px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
  .promocode-box.borderbox {
    width: 100%;
    max-height: 355px;
    background: #1784ed;
    padding: 30px 15px 20px 15px;
    -webkit-box-sizing: border-box;
    .item-box {
      width: 345px;
      background: linear-gradient(180deg, #fff6cf, #ffeaa1);
      border-radius: 4px;
      margin: 0 auto;
      display: flex;
      flex-direction: row;
      .item-left {
        width: 50%;
        display: flex;
        flex-direction: column;
        padding-top: 30px;
        padding-bottom: 30px;
        padding-left: 15px;
        box-sizing: border-box;
        .value {
          width: 100%;
          font-size: 20px;
          font-weight: 500;
          color: #333;
          line-height: 20px;
          margin-bottom: 20px;
          text-align: center;
        }

        .tit {
          display: inline-block;
          width: auto;
          height: 13px;
          font-size: 13px;
          font-weight: 400;
          color: #666;
          line-height: 13px;
          margin-left: 50px;
        }

        .btn-copy {
          width: 96px;
          height: 30px;
          border-radius: 15px;
          border: 1px solid #1784ed;
          cursor: pointer;
          margin-top: 20px;
          font-size: 14px;
          font-weight: 400;
          color: #1784ed;
          display: flex;
          align-items: center;
          justify-content: center;
          margin-left: 50px;
        }
      }

      .item-right {
        width: 50%;
        display: flex;
        flex-direction: column;
        padding-top: 30px;
        padding-bottom: 30px;
        padding-right: 15px;
        box-sizing: border-box;
        .value {
          width: 100%;
          font-size: 20px;
          font-weight: 500;
          color: #333;
          line-height: 20px;
          margin-bottom: 20px;
          text-align: center;
        }

        .tit {
          display: inline-block;
          width: auto;
          height: 13px;
          font-size: 13px;
          font-weight: 400;
          color: #666;
          line-height: 13px;
          margin-left: 50px;
        }
      }
    }

    .info {
      width: 100%;
      height: 119px;
      display: flex;
      flex-direction: column;
      margin-top: 22px;
      p {
        width: 100%;
        font-size: 13px;
        font-weight: 400;
        color: #fff;
        line-height: 19px;
        margin-bottom: 8px;
      }
    }
  }
  .type-box.borderbox {
    width: 100%;
    height: 54px;
    background-color: #fff;
    display: flex;
    flex-direction: row;
    justify-content: center;
    -webkit-box-sizing: border-box;
    .item.active {
      color: #3ca7fa;
      font-weight: 600;
      .actline {
        width: 56px;
        height: 4px;
        background: #3ca7fa;
        display: block;
      }
    }

    .item {
      min-width: 56px;
      height: 34px;
      cursor: pointer;
      text-align: center;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      align-items: center;
      font-size: 14px;
      font-weight: 400;
      color: #666;
      margin-right: 64px;
      margin-top: 20px;
      &:nth-child(3) {
        margin-right: 0;
      }
      .actline {
        width: 56px;
        height: 4px;
        background: #3ca7fa;
        display: none;
      }
    }
  }
  .empty-box {
    width: 100%;
    height: auto;
    float: left;
    text-align: center;
    padding-top: 50px;
    padding-bottom: 50px;
    .image-empty-item {
      display: inline-block;
      img {
        width: 120px;
        height: 120px;
        text-align: center;
      }
    }
  }
}
</style>
